package qq.android.wan.qq.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;

import qq.android.wan.qq.R;

/**
 * Created by Administrator on 2016/1/23.
 */
public class LoadActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //先判断在sp中是否已经登录过了，若是登录了，就显示该页面，否则就跳转到登录界面
        if(!isLogined()){
            Intent intent=new Intent(LoadActivity.this,LogoActivity.class);
            startActivity(intent);
            finish();
            return;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(R.layout.activity_load);
       new Thread(new Runnable() {
           @Override
           public void run() {
               try {

                   Thread.sleep(2000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               runOnUiThread(new Runnable() {
                   @Override
                   public void run() {
                       Intent intent=new Intent(LoadActivity.this,MainActivity.class);
                       startActivity(intent);
                       finish();
                   }
               });
           }
       }).start();

    }

    private boolean isLogined() {
        SharedPreferences sp= getSharedPreferences("user", Context.MODE_PRIVATE);
        String account=sp.getString("account","");
        if (account.equals("")){
            return false;
        }
        return true;
    }
}
